package com.lyEducation.core.base;

import javax.servlet.http.HttpServletResponse;

public enum SysConstants {
  PROJECT_ROLE("ROLE"),
  PROJECT_ROLE_ADMIN(PROJECT_ROLE.getValue() + "_admin"),
  PROJECT_ROLE_GENERALADMIN(PROJECT_ROLE.getValue() + "generalAdmin"),
  PROJECT_ROLE_USER(PROJECT_ROLE.getValue() + "_user"),
  PROJECT_SRC_PACKAGE_COM("com"),
  PROJECT_SRC_PACKAGE_LYEDUCATION("lyEducation"),
  PROJECT_SRC_PACKAGE_COM_LYEDUCATION(PROJECT_SRC_PACKAGE_COM.getValue() + "." + PROJECT_SRC_PACKAGE_LYEDUCATION.getValue()),
  //  com.lyEducation
  PROJECT_SRC_PACKAGE_CONTROLLERS("controllers"),
  PROJECT_SRC_PACKAGE_COM_LYEDUCATION_CONTROLLERS(PROJECT_SRC_PACKAGE_COM_LYEDUCATION.getValue() + "." + PROJECT_SRC_PACKAGE_CONTROLLERS),
  PROJECT_SWAGGER_UI_HTML_URL("/swagger-ui.html"),
  PROJECT_PLAY_ALI_PLAY_CALLBACK("aLiPlayCallback"),
  USERID("userId"),
  USERNAME("username"),
  PASSWORD("password"),
  CODE("code"),
  EMAIL("email"),
  MOBILE("mobile"),
  OK("OK"),
  EMAIL_ACTIVE_CODE_HASH("emailActiveCodeHash"),
  MOBILE_ACTIVE_CODE_HASH("mobileActiveCodeHash"),
  MOBILE_REGISTER_CODE_HASH("mobileRegisterCodeHash"),
  USER_ACCESS_TOKEN("User-Access-Token"),
  RESPONSE_CODE("Response-Code"),

  ROWS("rows"),

  TOTAL("total"),

  ID_CODE("id"),

  USER_TOKEN("userToken");
  private final String value;

  private SysConstants(String value) {
    this.value = value;
  }

  public static void CorsRegistry(HttpServletResponse response) {
    response.setHeader("Access-Control-Allow-Origin", "*");
    response.setHeader("Access-Control-Allow-Headers", "*");
    StringBuffer exposeHeaders = new StringBuffer(SysConstants.RESPONSE_CODE.value);
    exposeHeaders.append(",");
    exposeHeaders.append(SysConstants.USER_ACCESS_TOKEN.value);
    response.setHeader("Access-Control-Expose-Headers", exposeHeaders.toString());
  }

  public String getValue() {
    return value;
  }
}
